package com.photoeditor.demo.ui.widget.image;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;


public class PreViewPager extends ViewPager {

    private boolean mEnabled = true;

    public PreViewPager(Context context) {
        super(context);
    }

    public PreViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setPagingEnabled(boolean enabled) {
        mEnabled = enabled;
    }


    @Override
    public boolean onInterceptTouchEvent(MotionEvent arg0) {
        try {
            return mEnabled ? super.onInterceptTouchEvent(arg0) : false;
        } catch (Throwable e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent arg0) {
        try {
            return mEnabled ? super.onTouchEvent(arg0) : false;
        } catch (Throwable e) {
            e.printStackTrace();
        }
        return false;
    }
}
